#include "pixitem.h"

pixItem::pixItem(QPixmap*pixmap)
{
    pix=*pixmap;
}

QRectF pixItem::boundingRect() const
{
    return QRectF(-2-pix.width()/2,-2-pix.height()/2,pix.width()+4,pix.height()+4);
    //图元放入场景的格式，以图像中心点局部坐标系的（0，0)作为基准点，向四周扩散开来放置图片，并且预留四周2的间隔
}

void pixItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->drawPixmap(-pix.width()/2,-pix.height()/2,pix);
}

